package org.yinweichen.llm_dataset_backend.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.yinweichen.llm_dataset_backend.DTO.CandidateAnswerCreateDTO;
import org.yinweichen.llm_dataset_backend.entity.CandidateAnswer;
import org.yinweichen.llm_dataset_backend.entity.CandidateAnswerId;
import org.yinweichen.llm_dataset_backend.service.CandidateAnswerService;

import java.util.List;

@RestController
@RequestMapping("/api/candidate-answers")
@RequiredArgsConstructor
public class CandidateAnswerController {
    private final CandidateAnswerService candidateAnswerService;

    @PostMapping
    public ResponseEntity<CandidateAnswer> create(@RequestBody CandidateAnswerCreateDTO request) {
        return candidateAnswerService.create(request);
    }

    @GetMapping("/by-question/{questionId}/{version}")
    public ResponseEntity<List<CandidateAnswer>> getByStandardQuestion(@PathVariable Long questionId, @PathVariable String version) {
        return candidateAnswerService.getByQuestion(questionId, version);
    }

    @DeleteMapping("/{id}/{version}")
    public void delete(@PathVariable Long id, @PathVariable String version) {
        candidateAnswerService.delete(id, version);
    }
}